<?php
/**
 * @user:andy
 * @date:2021/8/1
 * @company:http://www.sjdphp.com
 * @desc:
 */

namespace app\admin\business;


use app\common\server\Json;
use app\common\server\SystemLog;
use app\common\server\Tree;

class BoroughsBus extends BackBus
{
    public static function getLists($term,$field = '',$page = 0,$limit = 0,$order = ''){
        $model = self::getModelExample();

        ## 查询操作
        try{
            $lists = $model->where($term)->field($field)->page($page,$limit)->order($order)->select();
            $count = $model->where($term)->count();
        }catch(\Exception $e){
            SystemLog::insertLog($e->getMessage());
            return Json::error("系统繁忙,请稍后重试");
        }

        if(!empty($lists) && !empty($count)){
            return json(array("code" => 0,'msg' => '获取成功','count' => $count,'data' => Tree::getBoroughsLists($lists)));
        }else{
            return Json::error('空数据');
        }
    }
}